package Model;

import Behavior.FlyWithWings;
import Factory.ClothFactory;
import Impl.FlyBehaviorImpl;
import Impl.ShootBehavior;


/**
 * 增加与Shoot和fly的策略模式关系
 * setCloth()使用工厂创建衣服类
 */
public class Person extends Component{
    protected Cloth cloth;
    private ShootBehavior shootBehavior;
    private FlyBehaviorImpl flyBehavior;
    private String type;
    public String getType(){
        return type;
    }

    //使用工厂模式创建cloth对象
    public void setCloth(int opt){
        ClothFactory fac = new ClothFactory();
        this.cloth = fac.createCloth(opt);
    }
    public void work(){
        System.out.println("i am working");
    }

    public void display(){
        System.out.println("i am a person");
    }
    public void showCloth(){
        cloth.display();
    }
    public void performShoot(Duck duck){
        shootBehavior.shoot(duck);
    }
    public void performFly(){
        flyBehavior.fly();
    }
    public void setShootBehavior(ShootBehavior behavior){
        this.shootBehavior=behavior;
    }
    public void setFlyBehavior(FlyBehaviorImpl flyBehavior){
        this.flyBehavior = flyBehavior;
    }

    @Override
    public void showCloth2() {
        System.out.print("我穿了一件");
    }
}
